package program02;

import java.util.Scanner;

/**
 * @version 1.0
 * @since:
 * @ClassName:TipsAndRedraw
 * @author: Li Jiahui
 * @date: 2021-01-03 0:55
 */
public class TipsAndRedraw {
    //1.自定义成员变量
    String black;
    public static boolean work = true;
    public static int victory = 0;
    //2.自定义成员方法
    void play(){
        ChessAction chessAction = new ChessAction();
       Victory win = new Victory();
        do {
            if (work) {
                System.out.print("请黑方走一下棋，输入要走棋的横纵坐标路径：");
                scanner();
                chessAction.redrawChessBoard();
                win.win();
            } else {
                System.out.print("请白方走一下棋，输入要走棋的横纵坐标路径：");
                scanner();
                chessAction.redrawChessBoard();
                win.win();
            }
            work = !work;
        } while (victory <= 5);
    }
    void scanner(){
        //自定义DrawChessBoard对象的实例化
       /* DrawChessBoard drawChessBoard = new DrawChessBoard();*/
        Scanner scanner = new Scanner(System.in);
        int xb = scanner.nextInt();
        int yb = scanner.nextInt();
        if (xb<0 || xb > 15 ) {
            System.out.println("超出下棋范围，请重新下棋");
            work = !work;
            return;
        }
        if (yb<0 || yb > 15 ) {
            System.out.println("超出下棋范围，请重新下棋");
            work = !work;
            return;
        }
        if (DrawChessBoard.chessBoard[xb][yb] != "+"){
            System.out.println("此处已有落子，请重新摆棋");
            work = !work;
            return;
        }
        if (work) {
            DrawChessBoard.chessBoard[xb][yb] = "B";
            System.out.println(DrawChessBoard.chessBoard[xb][yb]);
        } else {
            DrawChessBoard.chessBoard[xb][yb] = "W";
            System.out.println(DrawChessBoard.chessBoard[xb][yb]);
        }
    }
}
